Mir

Merge lp:~vanvugt/mir/remove-callbacks-mir_connect into lp:~mir-team/mir/trunk

Proposed by Daniel van Vugt
Status: Rejected
Rejected by: Daniel van Vugt
Proposed branch: lp:~vanvugt/mir/remove-callbacks-mir_connect
Merge into: lp:~mir-team/mir/trunk
Diff against target: 743 lines (+73/-198)
17 files modified
examples/demo_client.c (+1/-6)
examples/demo_client_accelerated.cpp (+1/-7)
examples/demo_client_unaccelerated.c (+1/-7)
include/mir_client/mir_client_library.h (+3/-14)
include/mir_client/mir_client_library_lightdm.h (+1/-2)
src/client/mir_client_library.cpp (+13/-7)
src/client/mir_connection.cpp (+8/-8)
src/client/mir_connection.h (+3/-5)
tests/acceptance-tests/test_client_library.cpp (+16/-14)
tests/acceptance-tests/test_focus_management_api.cpp (+2/-10)
tests/acceptance-tests/test_surfaceloop.cpp (+6/-31)
tests/integration-tests/test_display_info.cpp (+1/-7)
tests/integration-tests/test_drm_auth_magic.cpp (+2/-8)
tests/integration-tests/test_error_reporting.cpp (+2/-25)
tests/integration-tests/test_surfaceloop.cpp (+8/-34)
tests/unit-tests/client/test_client_mir_surface.cpp (+1/-5)
tests/unit-tests/client/test_mir_connection.cpp (+4/-8)
To merge this branch: bzr merge lp:~vanvugt/mir/remove-callbacks-mir_connect
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Thomas Voß (community) Disapprove
Alan Griffiths Disapprove
Review via email: mp+147056@code.launchpad.net

Commit message

Remove mir_connect callback from the public API.

First pass at simplifying the client API by removing callbacks. This is part
of a greater effort to resolve LP: #1112195, with more proposals to come.

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

We were asked to provided a callback based API.

Ignoring the stakeholders (I'm sure Thomas can provide a list) by removing the callbacks they asked is a bad idea.

review: Disapprove
Revision history for this message
Thomas Voß (thomas-voss) wrote :

In our conversations, both our toolkit experts (loicm and kaleo) expressed a requirement for an asynchronous API based on callbacks and added support for that requirement. I will disapprove until we have clarified with the stakeholders.

review: Disapprove
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

The API is still asynchronous. I'm not sure the stakeholders even conceived that it could be so without callbacks. And if callbacks are still required, they should be attached to a MirWaitHandle in the spirit of:
  mir_callback_on_completion(waithandle, callback, data);

I hope we can resolve this. The API is presently so awful that I refuse to use it. And I won't be the only one.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

An alternate solution, as discussed in bug 1112195 is to simply add the synchronous functions that most people will want to use:
  connection = mir_connect(...);
Though that suggests the existing functions like "mir_connect" change to something like "mir_async_connect" or "mir_background_connect".

The approach proposed here however is a nice middle-ground, not requiring duplicate functions to elegantly support both asynchronous and synchronous operation.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Design issues should be discussed in bug 1112195...

But I have many possible compromise solutions in mine. Will propose later.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

*in mind

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Unmerged revisions

408. By Daniel van Vugt

Remove mir_connect callback from the public API.

First pass at simplifying the client API by removing callbacks. This is part
of a greater effort to resolve LP: #1112195, with more proposals to come.

407. By Alan Griffiths

3rd_party/android-input: remove reliance on hardware_legacy/power.(c|h).

Approved by Alexandros Frantzis, PS Jenkins bot.

406. By Alan Griffiths

3rd_party/android-input: remove reliance on cutils/atomic.(c|h).

Approved by Alexandros Frantzis, PS Jenkins bot.

405. By Alan Griffiths

3rd_party/android-input: move the files we want to keep to "input".

Approved by Thomas Voß, PS Jenkins bot.

404. By Kevin DuBois

remove the wrappers for <thread> and <chrono> that were used to work around poor stdlib support on android, now that we have proper support of these libraries in the chroot.

Approved by Alan Griffiths, PS Jenkins bot.

403. By Alan Griffiths

graphics: Silence "narrowing conversion" with g++ 4.7.

Approved by PS Jenkins bot, Kevin DuBois.

402. By Kevin DuBois

stride was not being put into the native window type correctly. This caused render glitches when client was rendering. Add test that catches this condition

fixes: bug #1111612. Fixes: https://bugs.launchpad.net/bugs/1111612.

Approved by Alexandros Frantzis, Robert Carr, PS Jenkins bot, Alan Griffiths.

401. By Alan Griffiths

various: An assortment of nitpicky tidy-up.

Approved by Alexandros Frantzis, PS Jenkins bot.

400. By Alan Griffiths

3rd_party/android-input: stub our small use of TextOutput.

Approved by Kevin DuBois, PS Jenkins bot.

399. By Daniel van Vugt

mir_client_library.h: Documentation cleanup

1. Make the comments properly C-compatible so that clients written in pure C
   can build. (LP: #1116104)
2. Fix invalid Doxygen syntax which was generating bad docs (LP: #1116120). Fixes: https://bugs.launchpad.net/bugs/1116104, https://bugs.launchpad.net/bugs/1116120.

Approved by PS Jenkins bot, Alan Griffiths.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/demo_client.c'
2--- examples/demo_client.c 2012-12-27 14:44:59 +0000
3+++ examples/demo_client.c 2013-02-07 10:24:19 +0000
4@@ -48,11 +48,6 @@
5 /// needs to be accessible both to callbacks and to the control function.
6 /// \snippet demo_client.c Callback_tag
7 ///\internal [Callback_tag]
8-// Callback to update MirDemoState on connection
9-static void connection_callback(MirConnection *new_connection, void *context)
10-{
11- ((MirDemoState*)context)->connection = new_connection;
12-}
13
14 // Callback to update MirDemoState on surface_create
15 static void surface_create_callback(MirSurface *new_surface, void *context)
16@@ -93,7 +88,7 @@
17 /// \snippet demo_client.c connect_tag
18 ///\internal [connect_tag]
19 // Call mir_connect and wait for callback to complete.
20- mir_wait_for(mir_connect(server, __PRETTY_FUNCTION__, connection_callback, &mcd));
21+ mir_wait_for(mir_connect(server, __PRETTY_FUNCTION__, &mcd.connection));
22 puts("Connected");
23 ///\internal [connect_tag]
24
25
26=== modified file 'examples/demo_client_accelerated.cpp'
27--- examples/demo_client_accelerated.cpp 2013-01-28 21:35:03 +0000
28+++ examples/demo_client_accelerated.cpp 2013-02-07 10:24:19 +0000
29@@ -32,12 +32,6 @@
30 static MirConnection *connection = 0;
31 static MirSurface *surface = 0;
32
33-static void set_connection(MirConnection *new_connection, void * context)
34-{
35- (void)context;
36- connection = new_connection;
37-}
38-
39 static void surface_create_callback(MirSurface *new_surface, void *context)
40 {
41 (void)context;
42@@ -76,7 +70,7 @@
43
44 puts("Starting");
45
46- mir_wait_for(mir_connect(socket_file, __PRETTY_FUNCTION__, set_connection, 0));
47+ mir_wait_for(mir_connect(socket_file, __PRETTY_FUNCTION__, &connection));
48 puts("Connected");
49
50 assert(connection != NULL);
51
52=== modified file 'examples/demo_client_unaccelerated.c'
53--- examples/demo_client_unaccelerated.c 2012-12-19 16:01:00 +0000
54+++ examples/demo_client_unaccelerated.c 2013-02-07 10:24:19 +0000
55@@ -30,12 +30,6 @@
56 static MirConnection *connection = 0;
57 static MirSurface *surface = 0;
58
59-static void set_connection(MirConnection *new_connection, void * context)
60-{
61- (void)context;
62- connection = new_connection;
63-}
64-
65 static void surface_create_callback(MirSurface *new_surface, void *context)
66 {
67 (void)context;
68@@ -136,7 +130,7 @@
69
70 puts("Starting");
71
72- mir_wait_for(mir_connect(socket_file, __PRETTY_FUNCTION__, set_connection, 0));
73+ mir_wait_for(mir_connect(socket_file, __PRETTY_FUNCTION__, &connection));
74 puts("Connected");
75
76 assert(connection != NULL);
77
78=== modified file 'include/mir_client/mir_client_library.h'
79--- include/mir_client/mir_client_library.h 2013-02-05 10:28:36 +0000
80+++ include/mir_client/mir_client_library.h 2013-02-07 10:24:19 +0000
81@@ -38,14 +38,6 @@
82 typedef struct MirWaitHandle MirWaitHandle;
83
84 /**
85- * Callback to be passed when issuing a mir_connect request.
86- * \param [in] connection the new connection
87- * \param [in,out] client_context context provided by client in calling
88- * mir_connect
89- */
90-typedef void (*mir_connected_callback)(MirConnection *connection, void *client_context);
91-
92-/**
93 * Callback to be passed when calling:
94 * - mir_surface_create
95 * - mir_surface_next_buffer
96@@ -146,16 +138,13 @@
97 * wait handle remains valid until the connection has been released.
98 * \param [in] server a name identifying the server
99 * \param [in] app_name a name referring to the application
100- * \param [in] callback callback function to be invoked when request
101- * completes
102- * \param [in,out] context passed to the callback function
103- * \return a handle that can be passed to mir_wait_for
104+ * \param [out] result where to store the connection handle on
105+ * completion.
106 */
107 MirWaitHandle *mir_connect(
108 char const *server,
109 char const *app_name,
110- mir_connected_callback callback,
111- void *client_context);
112+ MirConnection **result);
113
114 /**
115 * Test for a valid connection
116
117=== modified file 'include/mir_client/mir_client_library_lightdm.h'
118--- include/mir_client/mir_client_library_lightdm.h 2013-02-05 14:50:25 +0000
119+++ include/mir_client/mir_client_library_lightdm.h 2013-02-07 10:24:19 +0000
120@@ -40,8 +40,7 @@
121 char const *server,
122 int lightdm_id,
123 char const *app_name,
124- mir_connected_callback callback,
125- void *client_context);
126+ MirConnection **result);
127
128
129 /**
130
131=== modified file 'src/client/mir_client_library.cpp'
132--- src/client/mir_client_library.cpp 2013-02-05 18:12:46 +0000
133+++ src/client/mir_client_library.cpp 2013-02-07 10:24:19 +0000
134@@ -44,7 +44,8 @@
135 MirConnection error_connection;
136 }
137
138-MirWaitHandle* mir_connect(char const* socket_file, char const* name, mir_connected_callback callback, void * context)
139+MirWaitHandle* mir_connect(char const* socket_file, char const* name,
140+ MirConnection **result)
141 {
142
143 try
144@@ -57,12 +58,17 @@
145 log,
146 client_platform_factory);
147
148- return connection->connect(name, callback, context);
149+ return connection->connect(name, result);
150 }
151 catch (std::exception const& x)
152 {
153 error_connection.set_error_message(x.what());
154- callback(&error_connection, context);
155+
156+ // Test cases expect a non-null error connection but why not null
157+ // for simpler error handling?
158+ if (result)
159+ *result = &error_connection;
160+
161 return 0;
162 }
163 }
164@@ -195,8 +201,7 @@
165 char const *server,
166 int lightdm_id,
167 char const *app_name,
168- mir_connected_callback callback,
169- void *client_context)
170+ MirConnection **result)
171 try
172 {
173 auto log = std::make_shared<mcl::ConsoleLogger>();
174@@ -207,12 +212,13 @@
175 log,
176 client_platform_factory);
177
178- return connection->connect(lightdm_id, app_name, callback, client_context);
179+ return connection->connect(lightdm_id, app_name, result);
180 }
181 catch (std::exception const& x)
182 {
183 error_connection.set_error_message(x.what());
184- callback(&error_connection, client_context);
185+ if (result)
186+ *result = 0;
187 return 0;
188 }
189
190
191=== modified file 'src/client/mir_connection.cpp'
192--- src/client/mir_connection.cpp 2013-02-05 18:12:46 +0000
193+++ src/client/mir_connection.cpp 2013-02-07 10:24:19 +0000
194@@ -126,7 +126,7 @@
195 return new_wait_handle;
196 }
197
198-void MirConnection::connected(mir_connected_callback callback, void * context)
199+void MirConnection::connected(MirConnection **result)
200 {
201 /*
202 * We need to create the client platform after the connection has been
203@@ -136,14 +136,15 @@
204 platform = client_platform_factory->create_client_platform(this);
205 native_display = platform->create_egl_native_display();
206
207- callback(this, context);
208+ if (result)
209+ *result = this;
210+
211 connect_wait_handle.result_received();
212 }
213
214 MirWaitHandle* MirConnection::connect(
215 const char* app_name,
216- mir_connected_callback callback,
217- void * context)
218+ MirConnection **result)
219 {
220 connect_parameters.set_application_name(app_name);
221 server.connect(
222@@ -151,15 +152,14 @@
223 &connect_parameters,
224 &connect_result,
225 google::protobuf::NewCallback(
226- this, &MirConnection::connected, callback, context));
227+ this, &MirConnection::connected, result));
228 return &connect_wait_handle;
229 }
230
231 MirWaitHandle* MirConnection::connect(
232 int lightdm_id,
233 const char* app_name,
234- mir_connected_callback callback,
235- void * context)
236+ MirConnection **result)
237 {
238 connect_parameters.set_application_name(app_name);
239 connect_parameters.set_lightdm_id(lightdm_id);
240@@ -168,7 +168,7 @@
241 &connect_parameters,
242 &connect_result,
243 google::protobuf::NewCallback(
244- this, &MirConnection::connected, callback, context));
245+ this, &MirConnection::connected, result));
246 return &connect_wait_handle;
247 }
248
249
250=== modified file 'src/client/mir_connection.h'
251--- src/client/mir_connection.h 2013-02-05 18:12:46 +0000
252+++ src/client/mir_connection.h 2013-02-07 10:24:19 +0000
253@@ -71,14 +71,12 @@
254
255 MirWaitHandle* connect(
256 const char* app_name,
257- mir_connected_callback callback,
258- void * context);
259+ MirConnection **result);
260
261 MirWaitHandle* connect(
262 int lightdm_id,
263 const char* app_name,
264- mir_connected_callback callback,
265- void * context);
266+ MirConnection **result);
267
268 void select_focus_by_lightdm_id(int lightdm_id);
269
270@@ -128,7 +126,7 @@
271 struct SurfaceRelease;
272
273 void done_disconnect();
274- void connected(mir_connected_callback callback, void * context);
275+ void connected(MirConnection **result);
276 void released(SurfaceRelease );
277 void done_drm_auth_magic(mir_drm_auth_magic_callback callback, void* context);
278 };
279
280=== modified file 'tests/acceptance-tests/test_client_library.cpp'
281--- tests/acceptance-tests/test_client_library.cpp 2013-02-05 18:12:46 +0000
282+++ tests/acceptance-tests/test_client_library.cpp 2013-02-07 10:24:19 +0000
283@@ -53,12 +53,6 @@
284 {
285 }
286
287- static void connection_callback(MirConnection * connection, void * context)
288- {
289- ClientConfigCommon * config = reinterpret_cast<ClientConfigCommon *>(context);
290- config->connection = connection;
291- }
292-
293 static void create_surface_callback(MirSurface * surface, void * context)
294 {
295 ClientConfigCommon * config = reinterpret_cast<ClientConfigCommon *>(context);
296@@ -109,7 +103,8 @@
297 {
298 void exec()
299 {
300- mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this));
301+ mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
302+ &connection));
303
304 ASSERT_TRUE(connection != NULL);
305 EXPECT_TRUE(mir_connection_is_valid(connection));
306@@ -129,7 +124,8 @@
307 void exec()
308 {
309
310- mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this));
311+ mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
312+ &connection));
313
314 ASSERT_TRUE(connection != NULL);
315 EXPECT_TRUE(mir_connection_is_valid(connection));
316@@ -200,7 +196,8 @@
317
318 void exec()
319 {
320- mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this));
321+ mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
322+ &connection));
323
324 ASSERT_TRUE(connection != NULL);
325 EXPECT_TRUE(mir_connection_is_valid(connection));
326@@ -252,7 +249,8 @@
327 void exec()
328 {
329
330- mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this));
331+ mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
332+ &connection));
333
334 ASSERT_TRUE(connection != NULL);
335 EXPECT_TRUE(mir_connection_is_valid(connection));
336@@ -288,7 +286,8 @@
337 {
338 void exec()
339 {
340- mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this));
341+ mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
342+ &connection));
343 ASSERT_TRUE(connection != NULL);
344
345 MirPlatformPackage platform_package;
346@@ -314,7 +313,8 @@
347 {
348 void exec()
349 {
350- mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this));
351+ mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
352+ &connection));
353 ASSERT_TRUE(connection != NULL);
354
355 MirDisplayInfo display_info;
356@@ -338,7 +338,8 @@
357 {
358 void exec()
359 {
360- mir_wait_for(mir_connect("garbage", __PRETTY_FUNCTION__, connection_callback, this));
361+ mir_wait_for(mir_connect("garbage", __PRETTY_FUNCTION__,
362+ &connection));
363 ASSERT_TRUE(connection != NULL);
364
365 char const* error = mir_connection_get_error_message(connection);
366@@ -360,7 +361,8 @@
367 {
368 void exec()
369 {
370- mir_wait_for(mir_connect("garbage", __PRETTY_FUNCTION__, connection_callback, this));
371+ mir_wait_for(mir_connect("garbage", __PRETTY_FUNCTION__,
372+ &connection));
373
374 MirSurfaceParameters const request_params =
375 {
376
377=== modified file 'tests/acceptance-tests/test_focus_management_api.cpp'
378--- tests/acceptance-tests/test_focus_management_api.cpp 2013-02-05 18:12:46 +0000
379+++ tests/acceptance-tests/test_focus_management_api.cpp 2013-02-07 10:24:19 +0000
380@@ -56,12 +56,6 @@
381 {
382 }
383
384- static void connection_callback(MirConnection* connection, void* context)
385- {
386- ClientConfigCommon* config = reinterpret_cast<ClientConfigCommon *>(context);
387- config->connection = connection;
388- }
389-
390 static void create_surface_callback(MirSurface* surface, void* context)
391 {
392 ClientConfigCommon* config = reinterpret_cast<ClientConfigCommon *>(context);
393@@ -200,8 +194,7 @@
394 mir_test_socket,
395 lightdm_id,
396 __PRETTY_FUNCTION__,
397- connection_callback,
398- this));
399+ &connection));
400
401 ASSERT_TRUE(connection != NULL);
402
403@@ -229,8 +222,7 @@
404 mir_wait_for(mir_connect(
405 mir_test_socket,
406 __PRETTY_FUNCTION__,
407- connection_callback,
408- this));
409+ &connection));
410
411 wait_for(focus_ready);
412 mir_select_focus_by_lightdm_id(connection, lightdm_id);
413
414=== modified file 'tests/acceptance-tests/test_surfaceloop.cpp'
415--- tests/acceptance-tests/test_surfaceloop.cpp 2013-01-11 23:47:40 +0000
416+++ tests/acceptance-tests/test_surfaceloop.cpp 2013-02-07 10:24:19 +0000
417@@ -96,28 +96,6 @@
418 {
419 }
420
421- static void connection_callback(MirConnection * connection, void * context)
422- {
423- ClientConfigCommon * config = reinterpret_cast<ClientConfigCommon *>(context);
424- config->connected(connection);
425- }
426-
427- void connected(MirConnection * new_connection)
428- {
429- std::unique_lock<std::mutex> lock(guard);
430- connection = new_connection;
431- wait_condition.notify_all();
432- }
433-
434- void wait_for_connect()
435- {
436- std::unique_lock<std::mutex> lock(guard);
437- while (!connection)
438- wait_condition.wait(lock);
439- }
440-
441- std::mutex guard;
442- std::condition_variable wait_condition;
443 MirConnection * connection;
444 static const int max_surface_count = 5;
445 SurfaceSync ssync[max_surface_count];
446@@ -160,9 +138,8 @@
447 {
448 void exec()
449 {
450- mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this);
451-
452- wait_for_connect();
453+ mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
454+ &connection));
455
456 MirSurfaceParameters request_params =
457 {
458@@ -213,9 +190,8 @@
459 {
460 void exec()
461 {
462- mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this);
463-
464- wait_for_connect();
465+ mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
466+ &connection));
467
468 MirSurfaceParameters request_params =
469 {
470@@ -257,9 +233,8 @@
471 {
472 void exec()
473 {
474- mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this);
475-
476- wait_for_connect();
477+ mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
478+ &connection));
479
480 MirSurfaceParameters request_params =
481 {
482
483=== modified file 'tests/integration-tests/test_display_info.cpp'
484--- tests/integration-tests/test_display_info.cpp 2013-01-11 23:47:40 +0000
485+++ tests/integration-tests/test_display_info.cpp 2013-02-07 10:24:19 +0000
486@@ -106,12 +106,6 @@
487
488 };
489
490-void connection_callback(MirConnection* connection, void* context)
491-{
492- auto connection_ptr = static_cast<MirConnection**>(context);
493- *connection_ptr = connection;
494-}
495-
496 }
497
498 TEST_F(BespokeDisplayServerTestFixture, display_info_reaches_client)
499@@ -139,7 +133,7 @@
500 {
501 MirConnection* connection{nullptr};
502 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
503- connection_callback, &connection));
504+ &connection));
505
506 MirDisplayInfo info;
507
508
509=== modified file 'tests/integration-tests/test_drm_auth_magic.cpp'
510--- tests/integration-tests/test_drm_auth_magic.cpp 2013-02-05 18:12:46 +0000
511+++ tests/integration-tests/test_drm_auth_magic.cpp 2013-02-07 10:24:19 +0000
512@@ -83,12 +83,6 @@
513 MOCK_METHOD1(drm_auth_magic, void(unsigned int));
514 };
515
516-void connection_callback(MirConnection* connection, void* context)
517-{
518- auto connection_ptr = static_cast<MirConnection**>(context);
519- *connection_ptr = connection;
520-}
521-
522 void drm_auth_magic_callback(int status, void* client_context)
523 {
524 auto status_ptr = static_cast<int*>(client_context);
525@@ -127,7 +121,7 @@
526 {
527 MirConnection* connection{nullptr};
528 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
529- connection_callback, &connection));
530+ &connection));
531
532 int const no_error{0};
533 int status{67};
534@@ -176,7 +170,7 @@
535 {
536 MirConnection* connection{nullptr};
537 mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
538- connection_callback, &connection));
539+ &connection));
540
541 int status{67};
542
543
544=== modified file 'tests/integration-tests/test_error_reporting.cpp'
545--- tests/integration-tests/test_error_reporting.cpp 2013-02-05 18:12:46 +0000
546+++ tests/integration-tests/test_error_reporting.cpp 2013-02-07 10:24:19 +0000
547@@ -151,28 +151,6 @@
548 {
549 }
550
551- static void connection_callback(MirConnection * connection, void * context)
552- {
553- ClientConfigCommon * config = reinterpret_cast<ClientConfigCommon *>(context);
554- config->connected(connection);
555- }
556-
557- void connected(MirConnection * new_connection)
558- {
559- std::unique_lock<std::mutex> lock(guard);
560- connection = new_connection;
561- wait_condition.notify_all();
562- }
563-
564- void wait_for_connect()
565- {
566- std::unique_lock<std::mutex> lock(guard);
567- while (!connection)
568- wait_condition.wait(lock);
569- }
570-
571- std::mutex guard;
572- std::condition_variable wait_condition;
573 MirConnection * connection;
574 static const int max_surface_count = 5;
575 SurfaceSync ssync[max_surface_count];
576@@ -255,9 +233,8 @@
577 {
578 void exec()
579 {
580- mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this);
581-
582- wait_for_connect();
583+ mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
584+ &connection));
585
586 ASSERT_TRUE(connection != NULL);
587 EXPECT_FALSE(mir_connection_is_valid(connection));
588
589=== modified file 'tests/integration-tests/test_surfaceloop.cpp'
590--- tests/integration-tests/test_surfaceloop.cpp 2013-02-05 18:12:46 +0000
591+++ tests/integration-tests/test_surfaceloop.cpp 2013-02-07 10:24:19 +0000
592@@ -183,28 +183,6 @@
593 {
594 }
595
596- static void connection_callback(MirConnection * connection, void * context)
597- {
598- ClientConfigCommon * config = reinterpret_cast<ClientConfigCommon *>(context);
599- config->connected(connection);
600- }
601-
602- void connected(MirConnection * new_connection)
603- {
604- std::unique_lock<std::mutex> lock(guard);
605- connection = new_connection;
606- wait_condition.notify_all();
607- }
608-
609- void wait_for_connect()
610- {
611- std::unique_lock<std::mutex> lock(guard);
612- while (!connection)
613- wait_condition.wait(lock);
614- }
615-
616- std::mutex guard;
617- std::condition_variable wait_condition;
618 MirConnection * connection;
619 static const int max_surface_count = 5;
620 SurfaceSync ssync[max_surface_count];
621@@ -270,9 +248,8 @@
622 {
623 void exec()
624 {
625- mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this);
626-
627- wait_for_connect();
628+ mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
629+ &connection));
630
631 ASSERT_TRUE(connection != NULL);
632 EXPECT_TRUE(mir_connection_is_valid(connection));
633@@ -373,9 +350,8 @@
634 {
635 void exec()
636 {
637- mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this);
638-
639- wait_for_connect();
640+ mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
641+ &connection));
642
643 ASSERT_TRUE(connection != NULL);
644 EXPECT_TRUE(mir_connection_is_valid(connection));
645@@ -512,9 +488,8 @@
646 {
647 void exec()
648 {
649- mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this);
650-
651- wait_for_connect();
652+ mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
653+ &connection));
654
655 MirSurfaceParameters const request_params =
656 {
657@@ -561,9 +536,8 @@
658 {
659 void exec()
660 {
661- mir_connect(mir_test_socket, __PRETTY_FUNCTION__, connection_callback, this);
662-
663- wait_for_connect();
664+ mir_wait_for(mir_connect(mir_test_socket, __PRETTY_FUNCTION__,
665+ &connection));
666
667 MirSurfaceParameters const request_params =
668 {
669
670=== modified file 'tests/unit-tests/client/test_client_mir_surface.cpp'
671--- tests/unit-tests/client/test_client_mir_surface.cpp 2013-01-02 15:57:13 +0000
672+++ tests/unit-tests/client/test_client_mir_surface.cpp 2013-02-07 10:24:19 +0000
673@@ -201,10 +201,6 @@
674
675 namespace mt = mir::test;
676
677-void connected_callback(MirConnection* /*connection*/, void * /*client_context*/)
678-{
679-}
680-
681 struct CallBack
682 {
683 void msg() {}
684@@ -233,7 +229,7 @@
685 channel = mcl::make_rpc_channel("./test_socket_surface", logger);
686 connection = std::make_shared<MirConnection>(channel, logger, platform_factory);
687 MirWaitHandle* wait_handle = connection->connect("MirClientSurfaceTest",
688- connected_callback, 0);
689+ nullptr);
690 wait_handle->wait_for_result();
691 client_comm_channel = std::make_shared<mir::protobuf::DisplayServer::Stub>(channel.get());
692 }
693
694=== modified file 'tests/unit-tests/client/test_mir_connection.cpp'
695--- tests/unit-tests/client/test_mir_connection.cpp 2013-01-02 15:57:13 +0000
696+++ tests/unit-tests/client/test_mir_connection.cpp 2013-02-07 10:24:19 +0000
697@@ -98,10 +98,6 @@
698 std::shared_ptr<mcl::ClientPlatform> platform;
699 };
700
701-void connected_callback(MirConnection* /*connection*/, void * /*client_context*/)
702-{
703-}
704-
705 void drm_auth_magic_callback(int status, void* client_context)
706 {
707 auto status_ptr = static_cast<int*>(client_context);
708@@ -144,7 +140,7 @@
709 .WillOnce(Return(native_display));
710
711 MirWaitHandle* wait_handle = connection->connect("MirClientSurfaceTest",
712- connected_callback, 0);
713+ nullptr);
714 wait_handle->wait_for_result();
715
716 EGLNativeDisplayType connection_native_display = connection->egl_native_display();
717@@ -167,7 +163,7 @@
718 .Times(1);
719
720 MirWaitHandle* wait_handle = connection->connect("MirClientSurfaceTest",
721- connected_callback, 0);
722+ nullptr);
723 wait_handle->wait_for_result();
724
725 int const no_error{0};
726@@ -211,7 +207,7 @@
727 .WillOnce(Invoke(fill_display_info));
728
729 MirWaitHandle* wait_handle = connection->connect("MirClientSurfaceTest",
730- connected_callback, 0);
731+ nullptr);
732 wait_handle->wait_for_result();
733
734 MirDisplayInfo info;
735@@ -236,7 +232,7 @@
736 .WillOnce(Invoke(fill_display_info_100));
737
738 MirWaitHandle* wait_handle = connection->connect("MirConnectionTest",
739- connected_callback, 0);
740+ nullptr);
741 wait_handle->wait_for_result();
742
743 MirDisplayInfo info;

Subscribers

People subscribed via source and target branches